package com.lgy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lgy.dao.FinancingDao;
import com.lgy.pojo.Financing;
import com.lgy.service.IFinancingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinancingServiceImpl implements IFinancingService {
    @Autowired
    private FinancingDao financingDao;

    @Override
    public int deleteByPrimaryKey(Integer financingId) {
        return financingDao.deleteByPrimaryKey(financingId);
    }

    @Override
    public int insert(Financing record) {
        return financingDao.insert(record);
    }

    @Override
    public int insertSelective(Financing record) {
        return financingDao.insertSelective(record);
    }

    @Override
    public Financing selectByPrimaryKey(Integer financingId) {
        return financingDao.selectByPrimaryKey(financingId);
    }

    @Override
    public int updateByPrimaryKeySelective(Financing record) {
        return financingDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Financing record) {
        return financingDao.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Financing> getFinancingByCompanyId(Integer companyId, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Financing> financingList = financingDao.findAllByCompanyId(companyId);
        PageInfo<Financing> pageInfo = new PageInfo<>(financingList);
        return pageInfo;
    }
}
